package com.huatai.common.convert;

/**
 * @program: ht-system
 * @description: 转换
 * @author: songxiude
 * @create: 2023-01-31 14:30
 **/

import org.springframework.boot.convert.ApplicationConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver;

public class HtConversionService extends ApplicationConversionService {
    @Nullable
    private static volatile HtConversionService SHARED_INSTANCE;

    public HtConversionService() {
        this((StringValueResolver)null);
    }

    public HtConversionService(@Nullable StringValueResolver embeddedValueResolver) {
        super(embeddedValueResolver);
        super.addConverter(new EnumToStringConverter());
        super.addConverter(new StringToEnumConverter());
    }

    public static GenericConversionService getInstance() {
        HtConversionService sharedInstance = SHARED_INSTANCE;
        if (sharedInstance == null) {
            Class var1 = HtConversionService.class;
            synchronized(HtConversionService.class) {
                sharedInstance = SHARED_INSTANCE;
                if (sharedInstance == null) {
                    sharedInstance = new HtConversionService();
                    SHARED_INSTANCE = sharedInstance;
                }
            }
        }

        return sharedInstance;
    }
}

